#pragma once
#include <qlib/all.h>
#include <entt/entt.hpp>
#include "../render/render.hpp"

#include "./components.hpp"
#include "./models.hpp"

namespace qbe::adsorb {

struct Data {
  qlib::Vec2d point;      // 被吸附的点
  qlib::Vec2dArray edge;  // 被吸附的边
  uint8_t type;           // 被吸附的类型， 1： edge， 0：point
  double distance;        // 鼠标到吸附对象的最短距离
};

void adsorb_init(ecs::Commands commands, entt::registry& reg, ecs::Query query);
void adsorb_vert(entt::registry& reg, ecs::Commands commands, ecs::Query query);
void adsorb_render(entt::registry& reg, ecs::Query query);

class AdsorbPlugin : public ecs::Plugin {
 public:
  void build(ecs::App& app) override;
};

}  // namespace qbe::adsorb